package com.isaiah.oa.service.impl;

import com.isaiah.oa.mapper.UserMapper;
import com.isaiah.oa.pojo.User;
import com.isaiah.oa.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by haijun on 2017/12/2.
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> getUsers() {
        return userMapper.select();
    }

    @Transactional
    @Override
    public void addUser(User user) {
        try{
            userMapper.insertSelective(user);
        }catch (Exception e){
            e.printStackTrace();
            throw new RuntimeException("添加用户失败", e);
        }
    }
}
